-
Notifications
You must be signed in to change notification settings - Fork 3
fix: prevent shell injection vulnerabilities (SEC-4316) #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| run: | | ||
| # Use poetry to bump the version in pyproject.toml | ||
| poetry version "${{ steps.version.outputs.new_release_version }}" | ||
| poetry version "$NEW_RELEASE_VERSION" | ||
| # Specify the user name and email which is required to commit with a token auth | ||
| git config user.email "${{ inputs.git-user-name }}" | ||
| git config user.name "${{ inputs.git-user-email }}" | ||
| git config user.email "$GIT_USER_NAME" | ||
| git config user.name "$GIT_USER_EMAIL" | ||
| # Commit the bumped project version with a non-semver chore: commit message | ||
| git add pyproject.toml | ||
| git --no-pager diff --staged | ||
| git commit --author="${{ inputs.git-user-name }} <${{ inputs.git-user-email }}>" -m "chore: release ${{ steps.version.outputs.new_release_version }}" -m "[skip actions]" | ||
| git commit --author="$GIT_USER_NAME <$GIT_USER_EMAIL>" -m "chore: release $NEW_RELEASE_VERSION" -m "[skip actions]" | ||
| # Push the changes to the current (should be main) branch, if this is not a dry-run | ||
| # TODO: This might not be super safe, we should consider that this could |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using variable interpolation ${{...}} with github context data in a run: step could allow an attacker to inject their own code into the runner. This would allow them to steal secrets and code. github context data can have arbitrary user input and should be treated as untrusted. Instead, use an intermediate environment variable with env: to store the data and use the environment variable in the run: script. Be sure to use double-quotes the environment variable, like this: "$ENVVAR".
🍰 Fixed in commit d1c28c8 🍰
- Add env var for inputs.dry-run - Fix lines 104 and 109 with proper env variable usage - Semgrep findings: yaml.github-actions.security.run-shell-injection Jira: SEC-4316
|
🎉 This PR is included in version 2.4.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
🔒 Security Fix: Shell Injection Prevention
Issue
Fixes shell injection vulnerability identified in Jira ticket SEC-4316.
Semgrep Finding:
yaml.github-actions.security.run-shell-injection.run-shell-injectionAffected Files:
release-poetry-package/action.yaml(lines 82-93, 104, 109)What Changed
Modified GitHub Actions workflow file to prevent shell injection by using intermediate environment variables instead of direct interpolation of GitHub expressions in shell scripts.
Initial Fix:
NEW_RELEASE_VERSION,GIT_USER_NAME,GIT_USER_EMAILAdditional Fix (after Semgrep scan):
${{ inputs.dry-run }}→ env varDRY_RUN${{ steps.version.outputs.new_release_version }}→ use existing env varNEW_RELEASE_VERSIONPattern Applied:
run: | poetry version "${{ steps.version.outputs.new_release_version }}"Security Context
Direct interpolation of GitHub expressions (
${{ ... }}) in shell scripts can lead to command injection if the input contains shell metacharacters. By using environment variables as intermediaries, we ensure inputs are treated as data rather than executable code.Reference: GitHub Actions Security Hardening
Testing
Review Checklist